package com.android.delivery.api

import android.text.TextUtils
import com.ada.common.util.GsonUtil
import com.android.delivery.callback.DialogCallback
import com.android.delivery.callback.LzyResponse
import com.android.delivery.constant.Constants
import com.android.delivery.entity.*
import com.android.delivery.entity.request.OrderReq
import com.honghu.villagepost.entity.request.LogisticsOrderDetail
import com.lzy.okgo.OkGo
import org.json.JSONObject
import java.io.File
import java.util.*

/**
 * Created by mqwang on 2017/11/15.
 */
object ApiService : BaseApi() {

    /** 登录  */
    @JvmStatic
    fun login(tag: Any?,
              mobile: String?,
              smsCode: String?,
              callback: DialogCallback<LzyResponse<LoginInfo>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["mobile"] = mobile
        params["smsCode"] = smsCode

        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<LoginInfo>>(APIUrl.LOGIN)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /** 发送验证码 */
    @JvmStatic
    fun verifycode(tag: Any?,
                   mobile: String?,
                   callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["mobile"] = mobile

        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.SMS_CODE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    @JvmStatic
    fun location_order_history(tag: Any?,
                               type: Int,
                               current: Int?,

                               callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.LOCATION_ORDER_HISTORY)
                .tag(tag)
                .params("type", type)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    @JvmStatic
    fun pick_wait_take(tag: Any?,
                       current: Int,
                       callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.PICK_WAIT_TAKE)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    @JvmStatic
    fun pick_take(tag: Any?,
                  logisticsNo: String,
                  callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.PICK_TAKE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    @JvmStatic
    fun pick(tag: Any?,
             current: Int,
             state: Int,//状态，1：待揽件；2：已揽件；3：已打印 4：转单
             callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.PICK)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .params("state", state)
                .execute(callback)
    }

    @JvmStatic
    fun pick(tag: Any?,
             logisticsNo: String,
             callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.PICK)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    @JvmStatic
    fun order_arrived(tag: Any?,
                      current: Int,
                      callback: DialogCallback<LzyResponse<List<Arrived>>>?) {

        OkGo.get<LzyResponse<List<Arrived>>>(APIUrl.ORDER_ARRIVED)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    @JvmStatic
    fun order_arrived_items(tag: Any?,
                            driverId: Int,
                            current: Int,
                            callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.ORDER_ARRIVED_ITEMS)
                .tag(tag)
                .params("driverId", driverId!!)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }


    @JvmStatic
    fun logistics_rider_list(tag: Any?,
                             keywords: String,
                             current: Int,
                             callback: DialogCallback<LzyResponse<User>>?) {

        OkGo.get<LzyResponse<User>>(APIUrl.LOGISTICS_RIDER)
                .tag(tag)
                .params("keywords", keywords)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    @JvmStatic
    fun logistics_rider(tag: Any?,
                        id: String?,
                        role: Int,
                        realName: String,
                        mobile: String,
                        baseFeeRate: Double,
                        baseFeeDeliveryRate: Double,
                        excessWeightFeeRate: Double,
                        excessDistancePickFeeRate: Double,
                        excessDistanceDeliveryFeeRate: Double,
                        serviceDeliveryFeeRate: Double,
                        excessQuantityRate: Double,
                        firstQuantityRate: Double,
                        callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()

        params["mobile"] = mobile
        params["realName"] = realName
        params["role"] = role

        params["baseFeeRate"] = baseFeeRate
        params["baseFeeDeliveryRate"] = baseFeeDeliveryRate
        params["excessWeightFeeRate"] = excessWeightFeeRate
        params["excessDistancePickFeeRate"] = excessDistancePickFeeRate
        params["excessDistanceDeliveryFeeRate"] = excessDistanceDeliveryFeeRate
        params["serviceDeliveryFeeRate"] = serviceDeliveryFeeRate
        params["excessQuantityRate"] = excessQuantityRate
        params["firstQuantityRate"] = firstQuantityRate

        if (!TextUtils.isEmpty(id)) {//修改
            params["id"] = id
            val jsonObject = JSONObject(params)
            OkGo.put<LzyResponse<Any>>(APIUrl.LOGISTICS_RIDER)
                    .tag(tag)
                    .upJson(jsonObject)
                    .execute(callback)
        } else {//新增
            val jsonObject = JSONObject(params)
            OkGo.post<LzyResponse<Any>>(APIUrl.LOGISTICS_RIDER)
                    .tag(tag)
                    .upJson(jsonObject)
                    .execute(callback)
        }
    }

    @JvmStatic
    fun user_delete(tag: Any?,
                    id: String,
                    callback: DialogCallback<LzyResponse<Any>>?) {

        OkGo.delete<LzyResponse<Any>>(APIUrl.LOGISTICS_RIDER + "/" + id)
                .tag(tag)
                .execute(callback)
    }


    @JvmStatic
    fun transport(tag: Any?,
                  type: Int,//1 待上车 2待送达
                  callback: DialogCallback<LzyResponse<List<Transport>>>?) {

        OkGo.get<LzyResponse<List<Transport>>>(APIUrl.TRANSPORT)
                .tag(tag)
                .params("type", type!!)
                .execute(callback)
    }


    @JvmStatic
    fun transport_item(tag: Any?,
                       locationId: Int,
                       current: Int,
                       callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.TRANSPORT_ITEM)
                .tag(tag)
                .params("locationId", locationId!!)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }


    @JvmStatic
    fun location_order_transporting(tag: Any?,
                                    current: Int,
                                    callback: DialogCallback<LzyResponse<Logistics>>?) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.LOCATION_ORDER_TRANSPORTING)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    /** 用户信息  */
    @JvmStatic
    fun user_info(tag: Any?,
                  callback: DialogCallback<LzyResponse<User>>?) {

        OkGo.get<LzyResponse<User>>(APIUrl.USER)
                .tag(tag)
                .execute(callback)
    }

    /** 用户信息  */
    @JvmStatic
    fun getUserBalance(tag: Any?,
                       callback: DialogCallback<LzyResponse<User>>?) {

        OkGo.get<LzyResponse<User>>(APIUrl.USER_ACCOUNT)
                .tag(tag)
                .execute(callback)
    }

    /** 用户信息修改  */
    fun user_modify(tag: Any?,
                    id: String?,
                    avatar: String?,
                    nickname: String?,
                    mobile: String?,
                    sex: Int?,
                    callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["id"] = id
        params["avatar"] = avatar
        params["mobile"] = mobile
        params["nickname"] = nickname
        params["sex"] = sex

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.USER)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }


    /** 下车  */
    fun transport_unload(tag: Any?,
                         logisticsNoList: MutableList<String>?,
                         callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["logisticsNoList"] = logisticsNoList

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.TRANSPORT_UNLOAD)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /** 送达  */
    fun transport_arrive(tag: Any?,
                         logisticsNoList: MutableList<String>?,
                         callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["logisticsNoList"] = logisticsNoList

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.TRANSPORT_ARRIVE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /** 确认接车  */
    fun transport_Sign(tag: Any?,
                       logisticsNoList: MutableList<String>?,
                       callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["logisticsNoList"] = logisticsNoList

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.TRANSPORT_SIGN)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }


    /**
     * 扫码上车
     */
    @JvmStatic
    fun transport_scan(tag: Any?,
                       logisticsNo: String,
                       type: Int,
                       callback: DialogCallback<LzyResponse<Scan>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["logisticsNo"] = logisticsNo
        params["type"] = type

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Scan>>(APIUrl.TRANSPORT_SCAN)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 扫码下车
     */
    @JvmStatic
    fun transport_scan_down(tag: Any?,
                            logisticsNo: String,
                            callback: DialogCallback<LzyResponse<Scan>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["logisticsNo"] = logisticsNo

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Scan>>(APIUrl.TRANSPORT_SCAN_UNLOAD)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }


    /** 地址列表  */
    fun user_address(tag: Any?,
                     keywords: String,
                     current: Int,
                     callback: DialogCallback<LzyResponse<Addr>>?) {

        OkGo.get<LzyResponse<Addr>>(APIUrl.USER_ADDRESS)
                .tag(tag)
                .params("keywords", keywords)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)

    }


    /** 新增地址  */
    fun user_address(tag: Any?,
                     adcode: String?,
                     address: String?,
                     city: String?,
                     district: String?,
                     latitude: Double?,
                     longitude: Double?,
                     mobile: String?,
                     name: String?,
                     province: String?,
                     street: String?,
                     callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["adcode"] = adcode
        params["address"] = address
        params["city"] = city
        params["district"] = district
        params["latitude"] = latitude
        params["longitude"] = longitude
        params["mobile"] = mobile
        params["name"] = name
        params["province"] = province
        params["street"] = street

        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.USER_ADDRESS)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }


    /** 修改地址  */
    fun user_address(tag: Any?,
                     adcode: String?,
                     id: Int?,
                     address: String?,
                     city: String?,
                     district: String?,
                     latitude: Double?,
                     longitude: Double?,
                     mobile: String?,
                     name: String?,
                     province: String?,
                     street: String?,
                     callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["id"] = id
        params["adcode"] = adcode
        params["address"] = address
        params["city"] = city
        params["district"] = district
        params["latitude"] = latitude
        params["longitude"] = longitude
        params["mobile"] = mobile
        params["name"] = name
        params["province"] = province
        params["street"] = street

        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.USER_ADDRESS)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /** 地址删除  */
    fun user_address_delete(tag: Any?,
                            id: Int?,
                            callback: DialogCallback<LzyResponse<Any>>?) {

        OkGo.delete<LzyResponse<Any>>(APIUrl.USER_ADDRESS + "/" + id)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 文件上传
     */
    fun uploader(tag: Any?, file: File,
                 callback: DialogCallback<LzyResponse<FileResult>>) {
        val fileList: MutableList<File> = ArrayList()
        fileList.add(file)
        OkGo.post<LzyResponse<FileResult>>(APIUrl.UPLOAD_FILE) //                .upJson(jsonObject)
                .tag(tag)
                .isMultipart(true)
                .addFileParams("file", fileList)
//                .upFile(file) //                .upFile(file)
                .execute(callback)
    }


    fun uploader1(tag: Any?, file: File,
                  callback: DialogCallback<LzyResponse<Map<String, String>>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        val fileList: MutableList<File> = ArrayList()
        fileList.add(file)
        params["sign"] = getSign(params)
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Map<String, String>>>(APIUrl.BASE_URL) //                .upJson(jsonObject)
                .tag(tag)
                .addFileParams("userfile", fileList) //                .upFile(file)
                .execute(callback)
    }

    /**
     * 运单号结算
     * @param type 1：速配，2：零担
     */
    fun order_settle(tag: Any?,
                     logisticsOrder: OrderReq?,
                     type: Int,
                     callback: DialogCallback<LzyResponse<OrderReq>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        params["goodsInfo"] = logisticsOrder!!.goodsInfo
        params["payType"] = logisticsOrder!!.payType

        val receiverAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.receiverAddress), Map::class.java)
        val senderAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.senderAddress), Map::class.java)

        params["receiverAddress"] = receiverAddressMap
        params["senderAddress"] = senderAddressMap

        params["excessWeightFee"] = logisticsOrder!!.excessWeightFee

        params["type"] = type

        val jsonObject = JSONObject(params)

        OkGo.post<LzyResponse<OrderReq>>(APIUrl.ORDER_SETTLE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 运单创建
     */
    fun order_create(tag: Any?,
                     logisticsOrder: OrderReq?,
                     type: Int,
                     callback: DialogCallback<LzyResponse<Logistics>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        if (!TextUtils.isEmpty(logisticsOrder?.logisticsNo)) {
            params["logisticsNo"] = logisticsOrder?.logisticsNo
        }
        params["goodsInfo"] = logisticsOrder!!.goodsInfo
        params["payType"] = logisticsOrder!!.payType
        params["userMemo"] = logisticsOrder!!.userMemo

        val receiverAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.receiverAddress), Map::class.java)
        val senderAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.senderAddress), Map::class.java)

        params["receiverAddress"] = receiverAddressMap
        params["senderAddress"] = senderAddressMap

        params["excessWeightFee"] = logisticsOrder!!.excessWeightFee

        params["type"] = type

        val jsonObject = JSONObject(params)

        OkGo.post<LzyResponse<Logistics>>(APIUrl.ORDER_CREATE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 运单创建
     */
    fun order_modify(tag: Any?,
                     logisticsOrder: OrderReq?,
                     type: Int,
                     callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()

        if (!TextUtils.isEmpty(logisticsOrder?.logisticsNo)) {
            params["logisticsNo"] = logisticsOrder?.logisticsNo
        }
        params["goodsInfo"] = logisticsOrder!!.goodsInfo
        params["payType"] = logisticsOrder!!.payType
        params["userMemo"] = logisticsOrder!!.userMemo

        val receiverAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.receiverAddress), Map::class.java)
        val senderAddressMap = GsonUtil.parse(GsonUtil.toJson(logisticsOrder!!.senderAddress), Map::class.java)

        params["receiverAddress"] = receiverAddressMap
        params["senderAddress"] = senderAddressMap

        params["excessWeightFee"] = logisticsOrder!!.excessWeightFee

        params["type"] = type

        val jsonObject = JSONObject(params)

        OkGo.put<LzyResponse<Any>>(APIUrl.ORDER_DETAIL)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 取消订单
     */
    fun order_cancel(tag: Any?,
                     logisticsNo: String,
                     callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.ORDER_CANCEL)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 运单详情
     */
    fun order_details(tag: Any?,
                      logisticsNo: String,
                      callback: DialogCallback<LzyResponse<LogisticsOrderDetail>>?) {


        OkGo.get<LzyResponse<LogisticsOrderDetail>>(APIUrl.ORDER_DETAIL + "/" + logisticsNo)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 微信支付
     */
    @JvmStatic
    fun orderPayWx(tag: Any?,
                   logisticsNo: String,
                   callback: DialogCallback<LzyResponse<PayWxInfo>>?) {

        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<PayWxInfo>>(APIUrl.ORDER_PAY_WX)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 微信支付
     */
    @JvmStatic
    fun orderPayBalance(tag: Any?,
                        logisticsNo: String,
                        callback: DialogCallback<LzyResponse<Any>>?) {

        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.ORDER_PAY_BALANCE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    @JvmStatic
    fun deliveryList(tag: Any?,
                     type: Int,
                     current: Int,
                     callback: DialogCallback<LzyResponse<Logistics>>?) {

        if (type == 0) {
            OkGo.get<LzyResponse<Logistics>>(APIUrl.DELIVERY)
                    .tag(tag)
                    .params("current", current!!)
                    .params("size", Constants.PERPAGE)
                    .execute(callback)
        } else {
            OkGo.get<LzyResponse<Logistics>>(APIUrl.DELIVERY_HISTORY)
                    .tag(tag)
                    .params("current", current!!)
                    .params("size", Constants.PERPAGE)
                    .execute(callback)
        }
    }

    @JvmStatic
    fun packHistoryList(tag: Any?,
                        current: Int,
                        callback: DialogCallback<LzyResponse<Logistics>>?) {
        OkGo.get<LzyResponse<Logistics>>(APIUrl.PICK_HISTORY)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    /**
     * 上门自提
     * 配送类型，1：送货上门，2：自提
     */
    @JvmStatic
    fun deliveryTake(tag: Any?,
                     logisticsNo: String,
                     type: Int,
                     callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        params["deliveryType"] = type
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.DELIVERY_SIGN)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /** 账单明细列表  */
    fun user_account_list(tag: Any?,
                          current: Int,
                          callback: DialogCallback<LzyResponse<AccountBill>>?) {

        OkGo.get<LzyResponse<AccountBill>>(APIUrl.USER_ACCOUNT_BILL)
                .tag(tag)
                .params("current", current)
                .params("size", Constants.PERPAGE)
                .execute(callback)

    }

    /**
     * 转单
     */
    fun order_transfer(tag: Any?,
                       logisticsNo: String,
                       targetUserId: String,
                       callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        params["targetUserId"] = targetUserId
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.TRANSFER)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 指定派单
     */
    fun order_allocate(tag: Any?,
                       logisticsNo: String,
                       userId: String,
                       callback: DialogCallback<LzyResponse<Any>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        params["userId"] = userId
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.ORDER_ALLOCATE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 转单
     */
    fun orderTransferList(tag: Any?,
                          current: Int,
                          callback: DialogCallback<LzyResponse<Logistics>>?) {
        val params: MutableMap<String?, Any?> = HashMap()
        OkGo.get<LzyResponse<Logistics>>(APIUrl.TRANSFER)
                .tag(tag)
                .params("current", current)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    /**
     * 转单-接受
     */
    @JvmStatic
    fun acceptOrderTransfer(tag: Any?,
                            logisticsNo: String,
                            callback: DialogCallback<LzyResponse<Any>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.TRANSFER_CONFIM)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 转单-拒绝
     */
    @JvmStatic
    fun rejectOrderTransfer(tag: Any?,
                            logisticsNo: String,
                            callback: DialogCallback<LzyResponse<Any>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.TRANSFER_REFUSE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 接单
     */
    @JvmStatic
    fun deliveryTake(tag: Any?,
                     logisticsNo: String,
                     callback: DialogCallback<LzyResponse<Scan>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Scan>>(APIUrl.DELIVERY_TAKE)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    @JvmStatic
    fun getPrintCloudList(tag: Any?,
                          current: Int,
                          callback: DialogCallback<LzyResponse<CloudPrinter>>?) {

        OkGo.get<LzyResponse<CloudPrinter>>(APIUrl.PRINTER)
                .tag(tag)
                .params("current", current!!)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    /**
     * 打印
     */
    @JvmStatic
    fun printCloud(tag: Any?,
                   logisticsNo: String,
                   callback: DialogCallback<LzyResponse<Any>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["logisticsNo"] = logisticsNo
        val jsonObject = JSONObject(params)
        OkGo.post<LzyResponse<Any>>(APIUrl.PRINTER_PRINT)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 打印
     */
    @JvmStatic
    fun printerConn(tag: Any?,
                    deviceId: String,
                    callback: DialogCallback<LzyResponse<Any>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        params["deviceId"] = deviceId
        val jsonObject = JSONObject(params)
        OkGo.put<LzyResponse<Any>>(APIUrl.PRINTER_CONNECT)
                .tag(tag)
                .upJson(jsonObject)
                .execute(callback)
    }

    /**
     * 获取版本信息
     */
    @JvmStatic
    fun updateVersion(tag: Any?,
                      callback: DialogCallback<LzyResponse<Version>>) {
        OkGo.get<LzyResponse<Version>>(APIUrl.LAUNCH)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 获取网点端首页数据
     */
    fun getNetHome(tag: Any?,
                   callback: DialogCallback<LzyResponse<NetHome>>) {
        OkGo.get<LzyResponse<NetHome>>(APIUrl.NET_HOME)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 获取网点端首页数据
     */
    fun getQishouHome(tag: Any?,
                      callback: DialogCallback<LzyResponse<NetHome>>) {
        OkGo.get<LzyResponse<NetHome>>(APIUrl.QISHOU_HOME)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 获取司机端首页数据
     */
    fun getSijiHome(tag: Any?,
                    callback: DialogCallback<LzyResponse<NetHome>>) {
        OkGo.get<LzyResponse<NetHome>>(APIUrl.SIJI_HOME)
                .tag(tag)
                .execute(callback)
    }

    /**
     * 获取同城速递列表
     * @param type 1速运，2零担，3，同城代寄
     */
    @JvmStatic
    fun getCitySend(tag: Any?,
                    type: Int,
                    current: Int,
                    callback: DialogCallback<LzyResponse<Logistics>>) {

        OkGo.get<LzyResponse<Logistics>>(APIUrl.CITY_ACCEPT_LIST)
                .tag(tag)
                .params("logisticsType", type)
                .params("current", current)
                .params("size", Constants.PERPAGE)
                .execute(callback)
    }

    /**
     * 确认送达
     */
    @JvmStatic
    fun cityConfirmDelivery(tag: Any?,
                            logisticsNo: String,
                            callback: DialogCallback<LzyResponse<Any>>) {
        val params: MutableMap<String?, Any?> = HashMap()
        OkGo.put<LzyResponse<Any>>(APIUrl.CONFIRM_DELIVERY + "/" + logisticsNo)
                .tag(tag)
                .execute(callback)
    }
}